package cn.zz.veggie.application.assembler;

import cn.zz.veggie.model.domain.Product;
import cn.zz.veggie.model.enums.ProductStatus;
import cn.zz.veggie.model.query.ProductQuery;
import cn.zz.veggie.web.types.dto.mgmt.MgmtProductQueryDto;
import cn.zz.veggie.web.types.dto.mgmt.MgmtProductSaveDto;

/**
 * @author zhongq
 * @since 2024/4/4
 */
public class ProductAssembler {
	public static ProductQuery buildQuery(MgmtProductQueryDto dto) {
		final ProductQuery query = new ProductQuery();
		query.setLikeName(dto.getName());
		query.setStatus(ProductStatus.active.status);
		return query;
	}

	public static Product buildDomain(MgmtProductSaveDto dto) {
		final Product product = new Product();
		product.setId(dto.getId());
		product.setName(dto.getName());
		product.setStatus(dto.getStatus());
		product.setImage(dto.getImage());
		product.setPrice(dto.getPrice());
		product.setUnit(dto.getUnit());
		product.setSpec(dto.getSpec());
		return product;
	}
}